# encoding: utf-8
import logging

from .base import LOG_FILE_PATH


def make_log_with_time(file_name=LOG_FILE_PATH):
    from logging.config import dictConfig

    dictConfig({
        'version': 1,
        'formatters': {
            'default': {
                'format': '[%(asctime)s] %(levelname)s in %(pathname)s : %(message)s',
            },
        },
        'handlers': {
            'info_file': {
                'level': 'INFO',
                'class': 'logging.handlers.TimedRotatingFileHandler',
                'formatter': 'default',
                'when': 'D',
                'filename': file_name,
                'backupCount': 3
            }
        },
        'root': {
            'level': 'INFO',
            'handlers': ['info_file']
        }
    })


def make_log_with_file(file_name=LOG_FILE_PATH):
    from logging.config import dictConfig

    dictConfig({
        'version': 1,
        'formatters': {
            'default': {
                'format': '[%(asctime)s] %(levelname)s in %(pathname)s : %(message)s',
            },
        },
        'handlers': {
            'info_file': {
                'level': 'INFO',
                'class': 'logging.FileHandler',
                'formatter': 'default',
                'mode': 'w',
                'filename': file_name
            }
        },
        'root': {
            'level': 'INFO',
            'handlers': ['info_file']
        }
    })


# make_log_with_time()


if __name__ == '__main__':
    import logging
    make_log_with_time()
    logging.error('test 134')